package com.ruoyi.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.query.CustomDataConfigQuery;
import com.ruoyi.common.core.domain.vo.SelectOptionVO;
import com.ruoyi.service.CustomDataServiceImpl;
import com.ruoyi.vo.CustomDataResponseVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

/**
 * 自定义数据
 */
@RestController("自定义数据/")
@RequestMapping("/customerData/")
public class CustomerDataController extends BaseController {
    @Autowired
    private CustomDataServiceImpl customDataService;
    private Logger logger = LoggerFactory.getLogger(CustomerDataController.class);

    @RequestMapping(value = "parseSql")
    public Object parseSql(String sql) {
        CustomDataConfigQuery config = customDataService.parseSql(sql);
        return config;
    }

    @RequestMapping(value = "getDictType")
    public Object getDictType(String type) {
        List<SelectOptionVO> list = customDataService.getDictType(type);
        return list;
    }


    @RequestMapping(value = "getSelectOptionList")
    public Object getSelectOptionList(String dictType) {
        Object list = customDataService.getSelectOptionList(dictType);
        return list;
    }


    @RequestMapping(value = "/table/getList")
    public Object tableGetList(Page pageExt, String menuId, @RequestParam Map<String, Object> param) {
        CustomDataResponseVO rs = customDataService.tableGetList(pageExt, menuId, param);
        return success(rs);
    }
}